This application relates to a method and apparatus for executing computer programs and, specifically, to a method and apparatus that ensures that a computer program being downloaded and/or executed conforms to a programming platform standard.
Computer programs are usually written in some type of xe2x80x9chigh level languagexe2x80x9d such as Java, C++ or Visual Basic. (xe2x80x9cJavaxe2x80x9d is a trademark or registered trademark in the United States and other countries of Sun Microsystems, Inc.) High level languages are more easily understood by human beings than are programs written in the machine language understood by computers.
Some high level languages are designed to be executed in a runtime environment, such as the Java runtime environment. Such an environment is often called a xe2x80x9cplatform.xe2x80x9d Such a platform will often have a standard API (Application Program Interface). A xe2x80x9cplatform standardxe2x80x9d defines, for example, what is an allowable class or method in the language and what is not. A platform standard also defines what kinds of actions the program can take. For example, the Java programming language was developed by Sun Microsystems, Inc. Sun Microsystems, Inc. has recently defined a platform standard known as xe2x80x9cPure Java.xe2x80x9d Pure Java programs are programs that adhere to the Pure Java standard. Even though a particular class or method may be syntactically allowable by the Java language specification, it may not be allowed by the Pure Java compatibility test suite. For example, xe2x80x9cextensionsxe2x80x9d to the Java API may not conform to xe2x80x9cPure Java.xe2x80x9dp A program that does not conform to the Pure Java standard can pose risks to a computer system. For example, such a program may allow computer viruses to infiltrate the system. As an example, the Java language generally allows the execution of xe2x80x9cnativexe2x80x9d code (i.e., code written in a programming language other than Java) from within a Java program. Such native code can include a virus program capable of escaping from the Java runtime environment into other portions of the computer memory and storage media. Such viruses could corrupt a user""s hard drive, overflow the program stack, or perform similar types of damage, either intentionally or unintentionally. It is desirable to ensure that such damage does not occur. Thus, in the Pure Java standard, the user is not allowed to write calls to native methods.
Another risk is that a program not written in Pure Java is not guaranteed to be cross-platform compatible. A program written in Pure Java will run on any system with a Java runtime environment. A program that is not written in Pure Java may not run on all Java runtime environments.
Most conventional browsers for the World Wide Web allow a user to execute computer programs from within a Web page being viewed by the user. For example, if the user is using a Java-enabled browser to view a Web page and the user visits a Web page incorporating a Java applet, the browser causes the Java applet to be downloaded from a remote computer and executed by a Java runtime environment within the browser.
Current Java-enabled browsers include Netscape Communicator and Netscape Navigator, available from Netscape Communications Corporation and Internet Explorer, available from Microsoft Corporation.
Embodiments of the present invention provide a method and apparatus for ensuring that code being executed and/or loaded by a computer conforms to a platform standard. As an example, one embodiment of the present invention validates Pure Java platform standard conformance of Java programs downloaded from a remote server to ensure that they conform to the xe2x80x9cPure Javaxe2x80x9d platform standard. This checking can be performed at the time that the program is downloaded across a network firewall and/or at one or more times before and during the execution of the program.
In accordance with one embodiment of the invention, program code that conforms to the xe2x80x9cPure Javaxe2x80x9d platform standard should contain an indication within the code that the code conforms to the platform standard. In the described embodiment, whenever a computer program (xe2x80x9cfilesxe2x80x9d or xe2x80x9ccodexe2x80x9d) is downloaded across a firewall, the firewall checks to ensure that all code crossing the firewall contains such an indication. Code that does not indicate conformance with the Pure Java standard is not passed through the firewall. The runtime environment optionally also performs a similar check.
In addition, in another embodiment of the present invention, the runtime environment performs yet another check for each loaded file or class before execution. Alternatively, the runtime environment can check to ensure that every class, function, method, instruction (e.g., each instruction of the Java virtual machine, byte code, or p-code), or each group of instructions contains an indication of conformance to the Pure Java standard before execution.
Of course, unscrupulous code producers can indicate that their code conforms to the standard when, in fact, it does not. A check to determine whether a program alleges conformance will not catch xe2x80x9cdishonestxe2x80x9d code producers. Thus, another embodiment of the present invention also performs an additional runtime check of the code. This runtime check can be a static check prior to code execution. Alternately, a semantic check can be performed at predetermined times during program execution. Various embodiments of the present invention perform a runtime check at various points. Such checks are performed, for example, at any or all of the following: prior to loading a main class, prior to loading each class, prior to executing a main method, prior to executing each method, and prior to executing each instruction.
In yet another embodiment, xe2x80x9cruntimexe2x80x9d checking can also be done in the firewall, as long as it does not appreciably affect the performance of the firewall.
Another embodiment of the present invention allows validation of conformance of Java applications that are loaded into a machine in some way other than via a network. Such an embodiment may not include a check at the firewall, since the application may be loaded into the machine from a non-networked source. For example, a Web browser can be used to view local files (i.e., files resident on the same machine as the browser) that include Java instructions or applets. Because such instructions or applets may not have entered through the firewall, it is desirable to duplicate the check for indication of conformance during run time.
In accordance with the purpose of the invention, as embodied and broadly described herein, the invention relates to a method of verifying that a computer program written in a programming language conforms to a platform standard for the programming language, comprising the steps, performed by a data processing system of: receiving the computer program, by a firewall of the data processing system; determining, by the firewall, that the received computer program is a computer program of a type to be checked for conformance; determining whether the computer program contains an indication that it conforms to the platform standard; and passing the computer program through the firewall only when the computer program contains an indication that it conforms to a platform standard.
In further accordance with the purpose of the invention, as embodied and broadly described herein, the invention relates to a method of verifying that an application program written in a programming language conforms to a platform standard for the programming language, comprising the steps, performed by a data processing system of: receiving the application program, by an execution environment of the data processing system; from a source outside the execution environment; determining, by the execution environment, whether the application program contains an indication that it conforms to the platform standard; and executing the application program, by the execution environment, only when the execution environment determines that the application program contains an indication that it conforms to the platform standard.
A fuller understanding of the invention will become apparent and appreciated by referring to the following description and claims taken in conjunction with the accompanying drawings.